<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<script type="text/javascript">
<!--
	function bal_check_telfee_showHistory(uid) {
		$("#bal_check_telfee_history", $.pdialog.getCurrent()).loadUrl(
				"bal_showTelfeeCheckHistory.action",
				{
					uuid : uid
				},
				function() {
					$("#bal_check_telfee_history", $.pdialog.getCurrent()).find(
							"[layoutH]").layoutH();
				});
	}

	function bal_check_telfee_getTotalFee() {
		var conts = 0;
		var totalFee = $("#bal_check_telfee_totalFee", $.pdialog.getCurrent());
		var state = false;
		$("input[name=bal_check_payFee]", $.pdialog.getCurrent()).each(
				function() {
					for (var i = 0; i < $(this).length; i++) {
						if ($(this).val() != "") {
							conts += parseFloat($(this).val());
						} else {
							$(this).val("0.00");
						}

						if ($(this).attr("ext1") != $(this).val()) {
							$(this).css("color", "red");
							state = true;
						} else {
							$(this).css("color", "black");
						}
					}
				});
		if (state) {
			totalFee.css("color", "red");
		} else {
			totalFee.css("color", "black");
		}

		totalFee.html((conts).toFixed(2));
		$("#bal_check_telfee_chkFee", $.pdialog.getCurrent()).val(
				(conts).toFixed(2));
	}
	
	$("#bal_check_telfee_firstrow", $.pdialog.getCurrent()).click();
	
//-->
</script>
<div class="pageContent">
	<c:choose>
		<c:when test="${empty errorMsg }">
			<c:choose>
				<c:when test="${empty balList}">
					<font color="red">* 该单据无结算明细信息！</font>
					<Br/><Br/><Br/><Br/><Br/><Br/><Br/>
				</c:when>
				<c:otherwise>
					<form method="post" action="bal_checkApp.action"
						class="pageForm required-validate"
						onsubmit="return validateCallback(this, dialogAjaxDone)">
						<input name="uuid" type="hidden" value="${uuid }">
						<table width="100%">
							<tr>
								<td width="60%">
									<table id="bal_check_telfee_table" class="list" width="100%"
										targetType="dialog" layoutH="50">
										<thead>
											<tr>
												<th>序号</th>
												<th>学校</th>
												<th>结算日期</th>
												<th>部门</th>
												<th>拓展人员</th>
												<th>维护人员</th>
												<th>电话费</th>
												<th>操作员费用</th>
												<th>结算费用</th>
												<th>批复金额</th>
												<th>备注</th>
											</tr>
										</thead>
										<tbody>
										<c:if test="${status.index==0 }">
										id="bal_check_telfee_firstrow"
										</c:if>
											<c:forEach items="${balList }" var="bal" varStatus="status">
												<tr 
													<c:if test="${status.index==0 }">
														id="bal_check_telfee_firstrow" class="selected"
													</c:if>
													onclick="javascript:bal_check_telfee_showHistory('${bal.uuid}')">
													<td>${(status.index+1)}</td>
													<td>${bal.sclName }</td>
													<td><fmt:parseDate value="${bal.ywEndDate}"
															var="ywEndDate" pattern="yyyyMMdd" /> <fmt:formatDate
															value="${ywEndDate}" pattern="yyyy-MM-dd" /></td>
													<td>${bal.saleDeptName}</td>
													<td>${bal.saleUserName}</td>
													<td>${bal.saleKeepName}</td>
													<td><fmt:formatNumber value="${bal.telFee}"	type="number" pattern="￥0.00" /></td>
													<td><fmt:formatNumber value="${bal.operFee}"	type="number" pattern="￥0.00" /></td>
													<td><fmt:formatNumber value="${bal.balFee}"
															type="number" pattern="￥0.00" /></td>
													<td><input type="hidden" name="bal_check_uuid"
														value="${bal.uuid}"> <input class="number"
														ext1="<fmt:formatNumber value="${bal.balFee}" pattern="#0.00" />"
														onblur="javascript:bal_check_telfee_getTotalFee();" size="6"
														value="<fmt:formatNumber value="${bal.balFee}" pattern="#0.00" />"
														name="bal_check_payFee" class="number"></td>
													<td><textarea name="bal_check_declare" rows="2"
															class="textInput">${bal.specDeclare}</textarea></td>
												</tr>
											</c:forEach>
											<tr>
												<td colspan="9" align="right">合计：</td>
												<td><span id="bal_check_telfee_totalFee"
													style="font-weight: bold;">${totalFee}</span> <input
													type="hidden" class="number" id="bal_check_telfee_chkFee"
													name="chkFee" style="color: red;" value="${totalFee}">
												</td>
												<td><textarea name="specDeclare" rows="2"
														class="textInput"></textarea></td>
											</tr>
										</tbody>
									</table>
								</td>
								<td width="40%" style="vertical-align: top;">
									<div id="bal_check_telfee_history" class="unitBox">&nbsp;</div>
								</td>
							</tr>
						</table>
						<div class="formBar">
							<ul>
								<li><div class="buttonActive">
										<div class="buttonContent">
											<button type="submit">保存</button>
										</div>
									</div></li>
								<li>
									<div class="button">
										<div class="buttonContent">
											<button type="button" class="close">取消</button>
										</div>
									</div>
								</li>
							</ul>
						</div>
					</form>
				</c:otherwise>
			</c:choose>
		</c:when>
		<c:otherwise>
			<div style="padding: 5px;color: red;">页面加载错误！${errorMsg }</div>
		</c:otherwise>
	</c:choose>
</div>